<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ include file="include.jsp" %>
<%@ include file="menu.jsp" %>

<script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">

    $(document).ready(function() {


        $("#consumers").change(function() {
            var t = $(this).val();
            $("#consumers option[value=default]").hide();
            if (t != '') {
                $("#details").load('getDetails.htm', { 'target' : t });
                $("#details").show();
            }
        });

        $("#details").change(function() {
            var d = $(this).val();
            $("#details option[value=default]").hide();
            $("#format").show();
        });

        $("#format").change(function() {
            var d = $(this).val();
            $("#format option[value=default]").hide();
            $("#button").show();
        });

        $("#button").click(function() {
            var target = $("#consumers").val();
            if (target == '' || target == 'default') {
                alert('Выберите отчет');
                return;
            }

            var details = $("#details").val();
            if (details == '' || details == 'default') {
                alert('Выберите цель отчета');
                return;
            }

            var format = $("#format").val();
            if (format == '' || format == 'default') {
                alert('Выберите формат');
                return;
            }

            var url = "viewReport.htm?target=" + target + "&datails=" + details + "&format=" + format;
            //alert(url);
            $(this).attr("href", url);
            window.location = $(this).attr("href");
        });


    });


</script>


<style type="text/css">

    .grid {
        width: 1000px;
        margin: 0 auto;

    }

    body a {
        text-decoration: none;
    }

    .title {
        text-align: center;
        font-family: sans-serif;
        font-size: larger;
        color: #6699cc;
        width: 1000px;
        margin: 0 auto;

    }

    .grid div {
        float: left;
        padding: 20px;

    }

</style>

<div class="title">Получение отчетов</div>
<br>

<div class="grid">
    <fieldset>
        <div>
            <select id="consumers">
                <option selected="selected" value="default">Выберите отчет</option>
                <option value="user">Пользователь</option>
                <option value="resource">Ресурс</option>
                <%--<option value="host">Хост</option>--%>
            </select>
        </div>
        &nbsp;&nbsp;
        <div>
            <select id="details" name="details" style="display:none;"></select>
        </div>
        &nbsp;&nbsp;
        <div>
            <select name="format" id="format" style="display:none;">
                <option selected="selected" value="default">Выберите формат</option>
                <option value="pdf">pdf</option>
                <option value="html">html</option>
                <option value="xls">xls</option>
            </select>
        </div>

        <div>
            <a id="button" href="#" style="display:none;">Получить отчет</a>
        </div>
    </fieldset>

</div>